<?php
include_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();

class RegisterForm1 extends Zend_Form
{
	/**
	 * Register_Form_1
	 *
	 * @var Register_Form_1
	 */
	protected static $_instance;	
	
	/**
	 * Zend_View
	 *
	 * @var Zend_View
	 */
	static protected $_tmpView;	
	
	public function getInstance()
	{
		if(null == self::$_instance){	
			self::$_instance = new self();
		}
		
		return self::$_instance;
	}
	
	/**
	 * 
	 * Form for Register Step 1
	 *
	 */
	public function __construct($options = null)
	{
		
		if(null == self::$_tmpView)
		{
			self::$_tmpView = new Zend_View();
		}
		
		$this->setAttribs(array(
			'id' 	=> 'register-form1',
			'name' 	=> 'register-form1',
			'action'=> $installDir['value'].'userpanel.php?ad=ud',
			'method'=> 'POST'
		));
		
		$this->clearDecorators();
		
		/*** Primary Contact ***/
		$title = new Zend_Form_Element_Select('accTitle');
		$title->setLabel('Title: ')
			  ->setMultiOptions(array(
			  	'Mr.' => 'Mr.',
			  	'Mrs.' => 'Mrs.'
			  ))
			  ->setAttrib('id','acc-title')
			  ->setRequired(TRUE);

		$firstName = new Zend_Form_Element_Text('accFirstName');
		$firstName->setLabel('First name: ')
				  ->setAttrib('id','acc-firstname')
				  ->setRequired(TRUE)
				  ->addValidator('NotEmpty',TRUE);
				  
		$lastName = new Zend_Form_Element_Text('accLastName');
		$lastName->setLabel('Last name: ')
				  ->setAttrib('id','acc-lastname')
				  ->setRequired(TRUE)
				  ->addValidator('NotEmpty',TRUE);
			  
		$phoneNumber = new Zend_Form_Element_Text('accContactPhone');
		$phoneNumber->setLabel('Contact phone: ')
				  ->setAttrib('id','acc-contactphone')
				  ->setRequired(TRUE)
				  ->addValidator('NotEmpty',TRUE)
				  ->addValidator('Digits',TRUE);

		$email = new Zend_Form_Element_Text('accContactEmail');
		$email->setLabel('Contact email: ')
				  ->setAttrib('id','acc-email')
				  ->setRequired(TRUE)
				  ->addValidator('NotEmpty',TRUE)
				  ->addValidator('EmailAddress',TRUE)
				  ->addDecorator('HtmlTag', array('tag' => 'ul'));
		/*** End Primary Contact ***/
		
		/*** Company Information ***/
		$bizName = new Zend_Form_Element_Text('accBusinessName');
		$bizName->setLabel('Business name: ')
				->setAttrib('id','acc-businessname')
				->setRequired(TRUE)
				->addValidator('NotEmpty',TRUE);
				
		$bizAddress1 = new Zend_Form_Element_Text('accBusinessAddressLine1');
		$bizAddress1->setLabel('Business Address line 1: ')
					->setAttrib('id','acc-businessaddress1')
					->setRequired(TRUE)
					->addValidator('NotEmpty',TRUE);
				
		$bizAddress2 = new Zend_Form_Element_Text('accBusinessAddressLine2');
		$bizAddress2->setLabel('Business Address line 2: ')
					->setAttrib('id','acc-businessaddress2')
					->setRequired(TRUE);
				
		$city = new Zend_Form_Element_Text('accCity');
		$city->setLabel('City: ')
			 ->setAttrib('id','acc-city')
			 ->setRequired(TRUE)
			 ->addValidator('NotEmpty',TRUE);
				
		$state = new Zend_Form_Element_Text('accState');
		$state->setLabel('State/Province: ')
				->setAttrib('id','acc-state')
				->setRequired(TRUE);
				
		$zipcode = new Zend_Form_Element_Text('accZipCode');
		$zipcode->setLabel('Zip/Postal code: ')
				->setAttrib('id','acc-zipcode')
				->setRequired(TRUE)
				->addValidator('NotEmpty',TRUE)
				->addValidator('Digits',TRUE);
		
		$countryList = Zend_Locale::getTranslationList('territory','en',2);
		$country = new Zend_Form_Element_Select('accCountry');
		$country->setLabel('Country: ')
			  ->setMultiOptions($countryList)
			  ->setAttrib('id','acc-country')
			  ->setRequired(TRUE);
		/*** End Company Information ***/
		
		/*** Store Information ***/
		$storename = new Zend_Form_Element_Text('accStoreName');
		$storename->setLabel('Store name: ')
				  ->setAttrib('id','acc-storename')
				  ->setRequired(TRUE)
				  ->addValidator('NotEmpty',TRUE);

		$website = new Zend_Form_Element_Text('accWebsiteUrl');
		$website->setLabel('Website URL: ')
				->setAttrib('id','acc-websiteurl')
				->setRequired(TRUE)
				->addValidator('NotEmpty',TRUE);
		/*** End Store Information ***/
		
		$submit = new Zend_Form_Element_Submit('button');		
		$submit->setLabel('Update');
        $this->addElements(array($title, $firstName, $lastName, $phoneNumber, $email,
        						$bizName, $bizAddress1, $bizAddress2, $city, $state, $zipcode, $country,
        						$storename, $website,
        						$submit
        						));
        
		$this->addDecorator('FormElements')
			 ->addDecorator('HtmlTag', array('tag' => 'table'))
			 ->addDecorator('Form');
		$this->setElementDecorators(array(
		    'ViewHelper',
		    'Errors',
		    array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')),
		    array('Label', array('tag' => 'td')),
		    array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
		));
	}
	
	public function render()
	{
		return parent::render(self::$_tmpView);
	}	
}

?>